package workbenchService

import (
	"context"
	"errors"
	WS "h_rpcx/internet/service/wrokbenchService"
	"h_rpcx/serve/workbench/business"
)

type WorkbenchService struct {
	svc *business.ServiceContext
}

func NewWorkbenchService() *WorkbenchService {
	return &WorkbenchService{svc: business.NewServiceContext()}
}

func (s *WorkbenchService) MyArtist(ctx context.Context, req *WS.MyArtistReq, resp *WS.MyArtistResp) error {
	var work WS.MyArtist
	artist, err := work.GetMyArtist(req, s.svc.DB)
	if err != nil {
		return errors.New("出现了错误")
	}
	resp.BrokerCount = artist.BrokerCount
	resp.OperationCount = artist.OperationCount
	resp.ThisMonthAdd = artist.ThisMonthAdd
	resp.LastMonthAdd = artist.LastMonthAdd
	resp.ThisMonthSign = artist.ThisMonthSign
	resp.LastMonthSign = artist.LastMonthSign
	resp.ThisMothSum = artist.ThisMothSum
	resp.LastMothSum = artist.LastMothSum
	return nil
}

//列表
func (s *WorkbenchService) List(ctx context.Context, req *WS.ListReq, resp *WS.ListResp) error {
	var work WS.MyArtist
	list, err := work.ArtistList(req, s.svc.DB)

	if err != nil {
		return errors.New("没有数据")
	}
	inf := &WS.ListResp{Influencer: list.Influencer}
	resp.Influencer = inf.Influencer
	return nil
}
